<?php

	class Mod_pesquisa extends CI_Model{

		function __construct()
		{
			parent::__construct();
		}


		function pesquisa($search, $sample_check)
		{
			if(!empty($sample_check))
			{ 
			    foreach($sample_check as $key=>$value){ 
			        $s[] = "G_TIPO='".$value."'"; 
			    } 
			    $sample_check = "(" . implode(' OR ', $s) . ")"; 

			    $query = "SELECT * FROM giveaway WHERE $sample_check" . " AND g_titulo LIKE '%$search%'"; 
			    $result1 = $this->db->query($query);

				return $result1->result();
			}
			else if (empty($sample_check) && !empty($search))
			{
				$query = "SELECT * FROM giveaway WHERE g_titulo LIKE '%$search%'"; 
			    $result1 = $this->db->query($query);

				return $result1->result();
			}
			else
			{
				return false;
			}
		}

		function index_pesquisa($search)
		{
			if(!empty($search))
			{ 
			    $query = "SELECT * FROM giveaway WHERE g_titulo LIKE '%$search%'"; 
			    $result1 = $this->db->query($query);

				return $result1->result();
			}
			else
			{
				return false;
			}
		}

	}

?>